#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int k;
	char a, b;
	string s;
	cin >> k;
	cin >> s >> a >> b;
	int ans = 0, sum = 0;
	
	int left = 0, right = k - 1;
	while (right < s.size())
	{
		if (s[left++] == a) ans++;
		if (s[right++] == b) sum += ans;
	}
	cout << sum;
	return 0;
}